package com.example.project3;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.appcompat.app.AppCompatActivity;

public class InterestSelectActivity extends AppCompatActivity {
    private RadioGroup rgInterests;
    private Button btnConfirm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.interest_select_activity);

        rgInterests = findViewById(R.id.rg_interests);
        btnConfirm = findViewById(R.id.btn_confirm);

        btnConfirm.setOnClickListener(v -> {
            // 获取选中的兴趣
            int selectedId = rgInterests.getCheckedRadioButtonId();
            if (selectedId != -1) {
                RadioButton selectedRadio = findViewById(selectedId);
                String interest = selectedRadio.getText().toString();

                // 返回选择的兴趣给上一个页面
                Intent intent = new Intent();
                intent.putExtra("interest", interest);
                setResult(RESULT_OK, intent);
                finish(); // 关闭当前页面
            }
        });
    }
}